/*
 * @Author: szx
 * @Date: 2022-03-18 14:52:24
 * @LastEditTime: 2022-03-18 15:05:52
 * @Description:
 * @FilePath: \leetcode\400-499\452\452_2.js
 */
/**
 * @param {number[][]} points
 * @return {number}
 */
var findMinArrowShots = function (points) {
    points.sort((a, b) => a[0] - b[0]);
    let res = 1;
    let pos = -Infinity;
    for (let i = 1; i < points.length; i++) {
        if (points[i][0] > pos) {
            res++;
        }
        pos = Math.max(pos, points[i][1]);
    }
    return res;
};
console.log(
    findMinArrowShots([
        [10, 16],
        [2, 8],
        [1, 6],
        [7, 12]
    ])
);
console.log(
    findMinArrowShots([
        [1, 2],
        [3, 4],
        [5, 6],
        [7, 8]
    ])
);
